<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form name="f1">
      <button type="submit">提交</button>
    </form>
    <script>
      /*
            1. onsubmit form表单提交事件，必须要点击type=submit 按钮才能触发
            2. onsubmit 默认行为
        */
      document.f1.onsubmit = function () {
        console.log("hello");
      };
    </script>
  </body>
</html>
